package com.sq.ai.controller.adver;

import com.sq.ai.exception.AiRunTimeException;
import com.sq.common.exception.param.ParamNotComplete;
import com.sq.common.exception.param.RepeatDataException;
import com.sq.common.web.R;
import com.sq.common.web.domain.AjaxResult;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @Author Li sir
 * @Date 2024/10/23
 */
@RestControllerAdvice
public class GlobalExceptionHandler {


    @ExceptionHandler(RepeatDataException.class)
    public AjaxResult repeatData(RepeatDataException e){
        return AjaxResult.error(e.getMessage());
    }

    @ExceptionHandler(ParamNotComplete.class)
    public R paramNotComplete(ParamNotComplete e){
        return R.fail(e.getMessage());
    }


    @ExceptionHandler(AiRunTimeException.class)
    public AjaxResult aiRunTimeException(AiRunTimeException e){
        return AjaxResult.error(e.getMessage());
    }

}
